package com.younio.local.compnent;


import com.younio.local.LocalApplication;
import com.younio.local.service.JbService2;
import com.younio.local.service.SynDerbyMysql;
import com.younio.local.service.Toast;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@Order
public class SystemStarter implements CommandLineRunner {

    @Autowired
    private JbService2 jbService;

    @Autowired
    private SynDerbyMysql synDerbyMysql;

    @Override
    public void run(String... args) {
        try {
            LocalApplication.setLabel("开始查询");
            jbService.resetIndex();
            LocalApplication.setLabel("初始化索引");
            synDerbyMysql.init();
            SynDerbyMysql.started = true;
            LocalApplication.setLabel("启动成功,运行中");
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("==============================================================================");
        log.info("=========================程序启动成功 开始读取天马数据库==========================");
        log.info("==============================================================================");
        Toast.error("程序启动成功", "程序启动成功");
    }
}
